// components/selectOtherPorjectDialog/selectOtherProjectDialog.js
Component({

  /**
   * 组件的属性列表
   */
  properties: {
    show: {
      type: Boolean,
      value: false,
      observer: function(newVal, oldVal) {
        if (newVal) {
          this.show();
        }
      }
    },
    userInfo: {
      type: Object,
      value: {},
      observer: function(newVal, oldVal) {
        this.setData({
          userInfo: newVal
        })
      }
    },
    orderMsg: {
      type: Object,
      value: {},
      observer: function(newVal, oldVal) {
        this.setData({
          orderMsg: newVal
        })
      }
    },
    pushUserIdsToUserType: {
      type: Boolean,
      value: false,
      observer: function(newVal, oldVal) {
        this.setData({
          pushUserIdsToUserType: newVal
        })
      }
    },
    hasChannelRefuseShowing: {
      type: Boolean,
      value: false,
      observer: function(newVal, oldVal) {
        this.setData({
          hasChannelRefuseShowing: newVal
        })
      }
    },
  },

  /**
   * 组件的初始数据
   */
  data: {
    array: ['选项1', '选项2', '选项3', '选项4'],
    index: [0],
    defaultBtn: false
  },

  /**
   * 组件的方法列表
   */
  methods: {
    cancel: function() {
      // 取消选择，关闭下拉选择框
    },
    confirm: function() {
      // 确认选择，关闭下拉选择框，并返回选择的结果
    },
    show: function() {
      var animation = wx.createAnimation({
        duration: 200,
        timingFunction: 'linear',
        transformOrigin: '50% 50% 0',
      })

      this.animation = animation

      animation.opacity(0).step(); // 淡出效果
      animation.opacity(1).step({ duration: 1000 });

      this.setData({
        animationData: animation.export()
      })

      wx.nextTick(() => {
        animation.scale(1, 1).step()
        this.setData({
          animationData: animation.export()
        })
      })
    },
    hide: function() {
      var animation = wx.createAnimation({
        duration: 200,
        timingFunction: 'linear',
        transformOrigin: '50% 50% 0',
      })

      this.animation = animation

      animation.opacity(1).step({ duration: 1000 }); // 淡入效果
      animation.opacity(0).step(); // 淡出效果

      this.setData({
        animationData: animation.export()
      })

      setTimeout(function() {
        animation.scale(1, 1).step()
        this.setData({
          animationData: animation.export()
        })
        // 动画结束后触发一个自定义事件
        setTimeout(function() {
          this.triggerEvent('animationend');
        }.bind(this), 500)
      }.bind(this))
    },
    // 获取内部宽度
    getInnerWidth: function() {
      var that = this;
      var query = this.createSelectorQuery();
      query.select('#container').boundingClientRect(function(rect) {
        if (rect.width && rect.width < 100) {
          that.setData({
            defaultBtn: true
          })
        }
      }).exec();
    },
    // 调用父组件方法
    // 修改
    goShowSubmit: function () {
      this.triggerEvent('goShowSubmit');
    },
    // 报价 ？ 修改
    goShowSubmitFirst: function () {
      this.triggerEvent('goShowSubmitFirst');
    },
    // 修改
    goShowSubmitSecond: function () {
      this.triggerEvent('goShowSubmitSecond');
    },
    // 去分配
    goPush: function () {
      this.triggerEvent('goPush');
    },
    // '修改' : '设置' 截至时间
    goSetBiddingEndTime: function () {
      this.triggerEvent('goSetBiddingEndTime');
    },
    // 去分配
    goPushFirstBidding: function () {
      this.triggerEvent('goPushFirstBidding');
    },
    // 拒绝
    goRefuseOrder: function () {
      this.triggerEvent('goRefuseOrder');
    },
    // 拒绝
    goChannelRefuse: function () {
      this.triggerEvent('goChannelRefuse');
    },
    // 重置订单
    goReSettingOrder: function () {
      this.triggerEvent('goReSettingOrder');
    },
    // 重置
    goReSettingOrderTime: function () {
      this.triggerEvent('goReSettingOrderTime');
    },
    // 放弃订单
    goAbandonOrder: function () {
      this.triggerEvent('goAbandonOrder');
    },
    // 处理
    goHandleExplain: function () {
      this.triggerEvent('goHandleExplain');
    }
  },

  /**
   * 组件生命周期函数
   */
  lifetimes: {
    attached: function() {
      this.getInnerWidth();
    }
  }
})